<?php
namespace App\Modules\IntegralGoods;

use App\Modules\AdapterApi;
use App\Services\IntegralGoods\GoodsIndex;

/**
 * 积分商品应用层
 * Class GoodsCategory
 * @package App\Modules\IntegralGoods
 */
class GoodsCategory extends AdapterApi
{
    //添加商品分类
    public function addGoodsCate()
    {
        $data = pick_array($this->postData,['app_id','other_app_read','is_public','name', 'pid','profile_pic','keywords','description','order', 'token']);

        return GoodsIndex::GoodsCategory()->addGoodsCate($data);
    }
    //编辑商品分类
    public function editGoodsCate()
    {
        $data = pick_array($this->postData,['other_app_read','is_public','name','id','profile_pic','keywords','description','order']);

        return GoodsIndex::GoodsCategory()->editGoodsCate($data);
    }

    //后台获取某商品分类的详细信息
    public function oneCateInfo(): array
    {
        $data = pick_array($this->postData,['id','token','app_id']);

        return GoodsIndex::GoodsCategory()->oneCateInfo($data);
    }
    /*
        根据id数组 启用/禁用一个或多个分类
        父类被禁用，则其所有子类也被禁用，开启同理
    */
    public function changeCateStatus(): array
    {
        $data = pick_array($this->postData, ['id', 'token', 'status']);

        return GoodsIndex::GoodsCategory()->changeCateStatus($data);
    }
    //获取商品分类列表
    public function goodsCateList(): array
    {
        $data = pick_array($this->postData, ['id', 'token', 'status']);

        return GoodsIndex::GoodsCategory()->goodsCateList($data);
    }
    //删除一个或多个商品分类
    public function delCate(): array
    {
        $data = pick_array($this->postData, ['id', 'token']);

        return GoodsIndex::GoodsCategory()->delCate($data);
    }

}